home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / MAILROOT.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  22KB  |  687 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                 This module was written by Bob Hartman                   */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Mail Control Routines                      */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. char *estring (int, int);
  51.  
  52. int do_mail (ADDRP baddr, int type) /* 1 = manual, 0 = normal, -1 = CM */
  53. {
  54.     int i;
  55.  
  56.     long callstart, callend;
  57.     long call_cost, call_cost_ths;
  58.  
  59.     long eh, em, es;
  60.  
  61.     b_init ();
  62.     caller = 1;
  63.     got_packet = 0;
  64.     got_arcmail = 0;
  65.     got_mail = 0;
  66.     sent_mail = 0;
  67.     no_WaZOO_Session = no_WaZOO;
  68.     callstart = 0L;
  69.  
  70. #ifdef MILQ
  71.     UsePaths = FALSE;
  72. #endif
  73.  
  74.     (void) sprintf (junk, "%s", Full_Addr_Str (baddr));
  75.  
  76.     called_addr = remote_addr = *baddr;     /* structure assignment */
  77.     SendMessage( node_hWnd, WM_COMMAND, GD_CRNT, (long)baddr );
  78.  
  79.     if (!net_params)
  80.         {
  81.         status_line (MSG_TXT(M_INSUFFICIENT_DATA));
  82.         set_xy ("");
  83.         return (0);
  84.         }
  85.  
  86.     if (!nodeproc (junk))
  87.         return (0);
  88.  
  89.     if (type > 0)
  90.         {
  91.         if (flag_file (TEST_AND_SET, &called_addr, 1))
  92.             {
  93.             if (CARRIER)
  94.                 mdm_hangup ();
  95.             return (0);
  96.             }
  97.  
  98.         if (CARRIER)                        /* called manually maybe? */
  99.             goto process_the_damned_mail;   /* yup, just do some mail */
  100.  
  101.  
  102.         do_dial_strings ();
  103.         try_2_connect ((char *) (newnodedes.PhoneNumber));  /* try to connect */
  104.         }
  105.     else
  106.         {
  107.         /* If this is supposed to be only local, then get out if it isn't */
  108.         if (type == 0)
  109.            {
  110.            if (e_ptrs[cur_event].behavior & MAT_LOCAL)
  111.                {
  112.                if (e_ptrs[cur_event].node_cost < 0)
  113.                    {
  114.                    if ((int) newnodedes.RealCost < -e_ptrs[cur_event].node_cost)
  115.                        {
  116.                        return (0);
  117.                        }
  118.                    }
  119.                else
  120.                    {
  121.                    if ((int) newnodedes.RealCost > e_ptrs[cur_event].node_cost)
  122.                        {
  123.                        return (0);
  124.                        }
  125.                    }
  126.                }
  127.            /* If it is supposed to be 24 hour mail only, get out if it isn't */
  128.            if ((newnodelist || version7) && 
  129.                (!(e_ptrs[cur_event].behavior & MAT_NOMAIL24)) &&
  130.                (!(newnodedes.NodeFlags & B_CM)))
  131.                return (0);
  132.            /* If we aren't supposed to send to CM's now, get out */
  133.            if ((newnodelist || version7) &&
  134.                (e_ptrs[cur_event].behavior & MAT_NOCM) &&
  135.                (newnodedes.NodeFlags & B_CM))
  136.                return (0);
  137.            }
  138.  
  139.         /* Try to connect */
  140.  
  141.         if (flag_file (TEST_AND_SET, &called_addr, 1))
  142.             {
  143.             if (CARRIER)
  144.                 mdm_hangup ();
  145.             return (0);
  146.             }
  147.  
  148.         do_dial_strings ();
  149.         if (un_attended && fullscreen)
  150.             {
  151.             sb_move (hold_hWnd, 2, 1);
  152.             sb_wa (hold_hWnd, colors.calling, 31);
  153.             }
  154.  
  155.         callstart = time (NULL);
  156.  
  157.         if (!blank_on_key)
  158.             screen_blank = 0;
  159.  
  160.         if ((i = try_1_connect ((char *) (newnodedes.PhoneNumber))) < 0)
  161.             {
  162.             if (un_attended && fullscreen)
  163.                 {
  164.                 sb_move (hold_hWnd, 2, 1);
  165.                 sb_wa (hold_hWnd, colors.hold, 31);
  166.                 }
  167.             (void) flag_file (CLEAR_FLAG, &called_addr, 1);
  168.             return (i);
  169.             }
  170.         }
  171.  
  172. process_the_damned_mail:
  173.  
  174.     if (CARRIER)                                         /* if we did,        */
  175.         {
  176.         if (type > 0)
  177.            callstart = time (NULL);
  178.  
  179.         b_session (1);                                  /* do a mail session  */
  180.  
  181.         callend = time (NULL);
  182.         hist.last_Elapsed = callend - callstart;
  183.  
  184.         eh = (callend - callstart) / 3600L;
  185.         em = ((callend - callstart) / 60L) - (eh * 60L);
  186.         es = (callend - callstart) - (eh * 3600L) - (em * 60L);
  187.  
  188.         hist.callcost += (call_cost = cost_of_call (callstart, callend));
  189.  
  190.         call_cost_ths = call_cost % 100L;               /* Separate dollars & */
  191.         call_cost = call_cost / 100L;                   /* cents for formats  */
  192.  
  193. #ifdef MILQ
  194.         sprintf( last_Elapsed_Str,
  195.                  "%02d:%02d:%02d",
  196.                    eh, em, es );
  197.         sb_puts( node_Elapsed, last_Elapsed_Str );
  198. #endif
  199.         status_line (MSG_TXT(M_NODE_COST), Full_Addr_Str (baddr), 
  200.                         eh, em, es, call_cost, call_cost_ths);
  201.         mdm_hangup ();
  202.  
  203. #ifdef MILQ
  204.         UsePaths = FALSE;
  205. #en